package br.folhapagamento.dado;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public abstract class DAOFactory {

	private static String JDBC_DRIVER  = "com.mysql.jdbc.Driver";  
    private static String DATABASE_URL = "jdbc:mysql://localhost/folhapagamento";  
    private static String LOGIN = "fpag";  
    private static String PASSWORD  = "usjt";

	private static Connection conexao;
    
    public static Connection criaConexao() {
    	// socket de conexao
		conexao = null;
		try {
			if (conexao == null || conexao.isClosed()) {
				Class.forName(JDBC_DRIVER);
				// estabelece a conexao com o banco de dados
				conexao = DriverManager.getConnection(DATABASE_URL, LOGIN, PASSWORD);
			}
		} catch (ClassNotFoundException cnfex) {
			// erros para o driver
			cnfex.printStackTrace();
		} catch (SQLException sqlex) {
			// erros SQL
			sqlex.printStackTrace();
		} catch (Exception ex) {
			// demais erros
			ex.printStackTrace();
		}

		return conexao;
    }
    public static IDAOCargo getClienteDAO() {
      return new DAOCargo();
    }

  }